package mao.leetcode.others;

import java.util.Stack;

public class leetcode232 {

        Stack<Integer> spush = new Stack<>();
        Stack<Integer> spop = new Stack<>();

        /** Initialize your data structure here. */
        public static void main(String[] args) {
            leetcode232 leetcode232 = new leetcode232();
            leetcode232.push(2);
            leetcode232.pop();
            System.out.println(leetcode232.empty());
        }


        /** Push element x to the back of queue. */
        public void push(int x) {
            while(spop.size() > 0){
                spush.push(spop.pop());
            }
            spush.push(x);
        }

        /** Removes the element from in front of queue and returns that element. */
        public int pop() {
            while(spush.size() > 0){
                spop.push(spush.pop());
            }
            return spop.pop();
        }

        /** Get the front element. */
        public int peek() {
            while(spush.size() > 0){
                spop.push(spush.pop());
            }
            return  spop.peek();

        }

        /** Returns whether the queue is empty. */
        public boolean empty() {
            return (spop.isEmpty() && spop.isEmpty());
        }
    }

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue obj = new MyQueue();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.peek();
 * boolean param_4 = obj.empty();
 */

